package com.ruoyi.work.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.work.domain.vo.BwStudentVo;
import com.ruoyi.work.domain.vo.StudentCorporationVo;
import com.ruoyi.work.domain.vo.TailAfterVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.work.domain.JyStudentCorporation;
import com.ruoyi.work.service.IJyStudentCorporationService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 学生公司中间Controller
 * 
 * @author ruoyi
 * @date 2024-06-06
 */
@RestController
@RequestMapping("/corporation")
public class JyStudentCorporationController extends BaseController
{
    @Autowired
    private IJyStudentCorporationService jyStudentCorporationService;

    /**
     * 查询学生公司中间列表
     */
    @RequiresPermissions("work:corporation:list")
    @GetMapping("/list")
    public TableDataInfo list(BwStudentVo bwStudentVo)
    {
        startPage();
//        List<JyStudentCorporation> list = jyStudentCorporationService.selectJyStudentCorporationList(jyStudentCorporation);
        List<BwStudentVo> list = jyStudentCorporationService.selectBwStudentInfoList(bwStudentVo);
        return getDataTable(list);
    }

    @GetMapping("/studentById/{id}")
    public R studentById(
            @PathVariable(name = "id")Long id
    )
    {
        return   jyStudentCorporationService.studentById(id);
    }

    /**
     * 导出学生公司中间列表
     */
    @RequiresPermissions("work:corporation:export")
    @Log(title = "学生公司中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JyStudentCorporation jyStudentCorporation)
    {
        List<JyStudentCorporation> list = jyStudentCorporationService.selectJyStudentCorporationList(jyStudentCorporation);
        ExcelUtil<JyStudentCorporation> util = new ExcelUtil<JyStudentCorporation>(JyStudentCorporation.class);
        util.exportExcel(response, list, "学生公司中间数据");
    }

    /**
     * 获取学生公司中间详细信息
     */
    @RequiresPermissions("work:corporation:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(jyStudentCorporationService.selectJyStudentCorporationById(id));
    }

    /**
     * 新增学生公司中间
     */
    @RequiresPermissions("work:corporation:add")
    @Log(title = "学生公司中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JyStudentCorporation jyStudentCorporation)
    {
        return toAjax(jyStudentCorporationService.insertJyStudentCorporation(jyStudentCorporation));
    }

    /**
     * 修改学生公司中间
     */
    @RequiresPermissions("work:corporation:edit")
    @PutMapping
    public R edit(@RequestBody BwStudentVo bwStudentVo)
    {
        return jyStudentCorporationService.updateJyStudentCorporation(bwStudentVo);
    }

    /**
     * 删除学生公司中间
     */
    @RequiresPermissions("work:corporation:remove")
    @Log(title = "学生公司中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jyStudentCorporationService.deleteJyStudentCorporationByIds(ids));
    }


    @PostMapping("/deptList")
    public R deptList()
    {
        return jyStudentCorporationService.selectDeptList();
    }

    /**上报返回 */
    @PostMapping("/reportBack")
    public R reportBack(@RequestBody StudentCorporationVo studentCorporationVo)
    {
        return jyStudentCorporationService.reportBack(studentCorporationVo);
    }

    /**上报入职 */
    @PostMapping("/reportEntry")
    public R reportEntry(@RequestBody StudentCorporationVo studentCorporationVo)
    {
        return jyStudentCorporationService.reportEntry(studentCorporationVo);
    }

    /**就业跟踪 */
    @PostMapping("/reportDown")
    public R reportDown(@RequestBody TailAfterVo tailAfterVo)
    {
        return jyStudentCorporationService.reportDown(tailAfterVo);
    }

    /**获取登录人 */
    @PostMapping("/getNickName")
    public SysUser getNickName()
    {

        return SecurityUtils.getLoginUser().getSysUser();
    }
}
